<html><head><title>/home/ambar/UVM/uvm/distrib/docs/html/src/comps/uvm_algorithmic_comparator.svh</title><link rel="stylesheet" type="text/css" href="../../styles/main.css"><script language=JavaScript src="../../javascript/main.js"></script></head><body class="FramedContentPage" onLoad="NDOnLoad()"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!--  Generated by Natural Docs, version Development Release 01-12-2008 (1.35 base) -->
<!--  http://www.naturaldocs.org  -->

<!-- saved from url=(0026)http://www.naturaldocs.org --> 








 <!--TOP - START OF CONTENT-->
<div id=Content>


 <!--CONTENT index=0 -->
<div class="CFile"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="uvm_algorithmic_comparator.svh" href="../../src/comps/uvm_algorithmic_comparator.svh">uvm_algorithmic_comparator.svh</a></h1><div class=CBody>

<!--START_ND_SUMMARY index=0-->
<div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable>
  <!-- index=0 -->

<tr class="SMain"><td colspan=2 class=SEntry><a href="#uvm_algorithmic_comparator.svh" >uvm_algorithmic_comparator.svh</a></td></tr>
<tr class=SMain><td colspan=2 class=SWideDescription></td></tr>
  <!-- index=1 -->

<tr class="SGroup"><td class=SEntry><a href="#Comparators" >Comparators</a></td><td class=SDescription>A common function of testbenches is to compare streams of transactions for equivalence. </td></tr></table></div></div><!--END_ND_SUMMARY-->
</div></div></div>




 <!--CONTENT index=1 -->
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="Comparators" href="../../src/comps/uvm_algorithmic_comparator.svh">Comparators</a></h3><div class=CBody><p>A common function of testbenches is to compare streams of transactions for equivalence.&nbsp; For example, a testbench may compare a stream of transactions from a DUT with expected results.</p><p>The UVM library provides a base class called <a href="uvm_in_order_comparator-svh.html#uvm_in_order_comparator#(T,comp_type,convert,pair_type)" class=LClass id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">uvm_in_order_comparator #(T,comp_type,convert,pair_type)</a> and two derived classes, which are <a href="uvm_in_order_comparator-svh.html#uvm_in_order_built_in_comparator#(T)" class=LClass id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">uvm_in_order_built_in_comparator #(T)</a> for comparing streams of built-in types and <a href="uvm_in_order_comparator-svh.html#uvm_in_order_class_comparator#(T)" class=LClass id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">uvm_in_order_class_comparator #(T)</a> for comparing streams of class objects.</p><p>The uvm_algorithmic_comparator also compares two streams of transactions; however, the transaction streams might be of different type objects.&nbsp; This device will use a user-written transformation function to convert one type to another before performing a comparison.</p></div></div></div>




 <!--CONTENT index=2 -->
<div class="CClass"><div class=CTopic><h2 class=CTitle><a name="uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER)" href="../../src/comps/uvm_algorithmic_comparator.svh">uvm_algorithmic_comparator #(BEFORE,AFTER,TRANSFORMER)</a></h2><div class=CBody><p>Compares two streams of data objects of different types, <i>BEFORE</i> and <i>AFTER</i>.</p><p>The algorithmic comparator is a wrapper around <a href="uvm_in_order_comparator-svh.html#uvm_in_order_class_comparator#(T)" class=LClass id=link10 onMouseOver="ShowTip(event, 'tt3', 'link10')" onMouseOut="HideTip('tt3')">uvm_in_order_class_comparator #(T)</a>.&nbsp; Like the in-order comparator, the algorithmic comparator compares two streams of transactions, the <i>BEFORE</i> stream and the <i>AFTER</i> stream.&nbsp; It is often the case when two streams of transactions need to be compared that the two streams are in different forms.&nbsp; That is, the type of the <i>BEFORE</i> transaction stream is different than the type of the <i>AFTER</i> transaction stream.</p><p>The uvm_algorithmic_comparator&rsquo;s <i>TRANSFORMER</i> type parameter specifies the class responsible for converting transactions of type <i>BEFORE</i> into those of type <i>AFTER</i>.&nbsp; This transformer class must provide a transform() method with the following prototype:</p><blockquote><pre>function AFTER transform (BEFORE b);</pre></blockquote><p>Matches and mistmatches are reported in terms of the <i>AFTER</i> transactions.&nbsp; For more information, see the <a href="uvm_in_order_comparator-svh.html#uvm_in_order_comparator#(T,comp_type,convert,pair_type)" class=LClass id=link11 onMouseOver="ShowTip(event, 'tt1', 'link11')" onMouseOut="HideTip('tt1')">uvm_in_order_comparator #(T,comp_type,convert,pair_type)</a> class.</p>

<!--START_ND_SUMMARY index=2-->
<div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable>
  <!-- index=2 -->

<tr class="SClass"><td colspan=2 class=SEntry><a href="#uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER)" id=link8 onMouseOver="ShowTip(event, 'tt8', 'link8')" onMouseOut="HideTip('tt8')">uvm_algorithmic_comparator #(BEFORE,AFTER,TRANSFORMER)</a></td></tr>
<tr class=SMain><td colspan=2 class=SWideDescription>Compares two streams of data objects of different types, <i>BEFORE</i> and <i>AFTER</i>.</td></tr>

  <!-- HIERARCHY -->
  <tr class="SHierarchy SIndent1 "><td colspan=2 class="SEntry SIndent1">Class Hierarchy</td></tr>
  <tr class="SPrototype SIndent1"><td colspan=2 class=SDescription>
      <div class=ClassHierarchy>
        <table border=0 cellspacing=0 cellpadding=0>
          <tr><td><div class=CHParent><div class=CHEntry><a href="../base/uvm_misc-svh.html#uvm_void" class=LGeneric id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">uvm_void</a></div></div></td></tr>
          <tr><td><div class=CHParent><div class=CHEntry><a href="../base/uvm_object-svh.html#uvm_object" class=LClass id=link5 onMouseOver="ShowTip(event, 'tt5', 'link5')" onMouseOut="HideTip('tt5')">uvm_object</a></div></div></td></tr>
          <tr><td><div class=CHParent><div class=CHEntry><a href="../base/uvm_report_object-svh.html#uvm_report_object" class=LClass id=link6 onMouseOver="ShowTip(event, 'tt6', 'link6')" onMouseOut="HideTip('tt6')">uvm_report_object</a></div></div></td></tr>
          <tr><td><div class=CHParent><div class=CHEntry><a href="../base/uvm_component-svh.html#uvm_component" class=LClass id=link7 onMouseOver="ShowTip(event, 'tt7', 'link7')" onMouseOut="HideTip('tt7')">uvm_component</a></div></div></td></tr>
          <tr><td><div class=CHCurrent><div class=CHEntry>uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER)</div></div></td></tr>
        </table>
      </div>
  </td></tr>



  <!-- PROTOTYPE -->
  <tr class="SPrototype SIndent1"><td colspan=2 class="SEntry SIndent1">Class Declaration</td></tr>
  <tr class="SPrototype SIndent1"><td colspan=2 class=SDescription>
    <blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype>
      <tr><td><table border=0 cellspacing=0 cellpadding=0><tr>
      <td class=PBeforeParameters colspan=5>class uvm_algorithmic_comparator #(</td>      </tr><tr><td>&nbsp;&nbsp;&nbsp;</td>      <td class=PType nowrap>type&nbsp;</td>
      <td class=PParameter nowrap>BEFORE</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%>int,</td>
      </tr><tr><td>&nbsp;&nbsp;&nbsp;</td>      <td class=PType nowrap>type&nbsp;</td>
      <td class=PParameter nowrap>AFTER</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%>int,</td>
      </tr><tr><td>&nbsp;&nbsp;&nbsp;</td>      <td class=PType nowrap>type&nbsp;</td>
      <td class=PParameter nowrap>TRANSFORMER</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%>int</td>
    </tr>
    <tr>
      <td class=PAfterParameters colspan=5>) extends uvm_component</td></tr>
      </table></td></tr>
    </table></blockquote>
</td></tr>

  <!-- index=3 -->

<tr class="SGroup SIndent1"><td class=SEntry><a href="#uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER).Ports" >Ports</a></td><td class=SDescription></td></tr>
  <!-- index=4 -->

<tr class="SPort SIndent2"><td class=SEntry><a href="#uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER).before_export" >before_export</a></td><td class=SDescription>The export to which a data stream of type BEFORE is sent via a connected analysis port. </td></tr>
  <!-- index=5 -->

<tr class="SPort SIndent2 SMarked"><td class=SEntry><a href="#uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER).after_export" >after_export</a></td><td class=SDescription>The export to which a data stream of type AFTER is sent via a connected analysis port. </td></tr>
  <!-- index=6 -->

<tr class="SGroup SIndent1"><td class=SEntry><a href="#uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER).Methods" >Methods</a></td><td class=SDescription></td></tr>
  <!-- index=7 -->

<tr class="SMethod SIndent2"><td class=SEntry><a href="#uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER).new" id=link9 onMouseOver="ShowTip(event, 'tt9', 'link9')" onMouseOut="HideTip('tt9')">new</a></td><td class=SDescription>Creates an instance of a specialization of this class. </td></tr></table></div></div><!--END_ND_SUMMARY-->
</div></div></div>




 <!--CONTENT index=3 -->
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER).Ports" href="../../src/comps/uvm_algorithmic_comparator.svh">Ports</a></h3></div></div>




 <!--CONTENT index=4 -->
<div class="CPort"><div class=CTopic><h3 class=CTitle><a name="uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER).before_export" href="../../src/comps/uvm_algorithmic_comparator.svh">before_export</a></h3><div class=CBody><p>The export to which a data stream of type BEFORE is sent via a connected analysis port.&nbsp; Publishers (monitors) can send in an ordered stream of transactions against which the transformed BEFORE transactions will (be compared.</p></div></div></div>




 <!--CONTENT index=5 -->
<div class="CPort"><div class=CTopic><h3 class=CTitle><a name="uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER).after_export" href="../../src/comps/uvm_algorithmic_comparator.svh">after_export</a></h3><div class=CBody><p>The export to which a data stream of type AFTER is sent via a connected analysis port.&nbsp; Publishers (monitors) can send in an ordered stream of transactions to be transformed and compared to the AFTER transactions.</p></div></div></div>




 <!--CONTENT index=6 -->
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER).Methods" href="../../src/comps/uvm_algorithmic_comparator.svh">Methods</a></h3></div></div>




 <!--CONTENT index=7 -->
<div class="CMethod"><div class=CTopic><h3 class=CTitle><a name="uvm_algorithmic_comparator#(BEFORE,AFTER,TRANSFORMER).new" href="../../src/comps/uvm_algorithmic_comparator.svh">new</a></h3>
    <blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype>
      <tr><td><table border=0 cellspacing=0 cellpadding=0><tr>
      <td class=PBeforeParameters nowrap>function new(</td>      <td class=PType nowrap>string&nbsp;</td>
      <td class=PParameter nowrap>name,</td>
      <td class=PDefaultValuePrefix>&nbsp;&nbsp;</td>
      <td class=PDefaultValue width=100%></td>
</tr><tr><td></td>      <td class=PType nowrap>uvm_component&nbsp;</td>
      <td class=PParameter nowrap>parent</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%>null,</td>
</tr><tr><td></td>      <td class=PType nowrap>TRANSFORMER&nbsp;</td>
      <td class=PParameter nowrap>transformer</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%>null</td>
      <td class=PAfterParameters nowrap>)</td></tr>
      </table></td></tr>
    </table></blockquote>
<div class=CBody><p>Creates an instance of a specialization of this class.&nbsp; In addition to the standard uvm_component constructor arguments, <i>name</i> and <i>parent</i>, the constructor takes a handle to a <i>transformer</i> object, which must already be allocated (no null handles) and must implement the transform() method.</p></div></div></div>

</div><!--Content-->



<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CClass>Compares two streams of data objects of the type parameter, T. </div></div><div class=CToolTip id="tt2"><div class=CClass>
    <blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype>
      <tr><td><table border=0 cellspacing=0 cellpadding=0><tr>
      <td class=PBeforeParameters colspan=5>class uvm_in_order_built_in_comparator #(</td>      </tr><tr><td>&nbsp;&nbsp;&nbsp;</td>      <td class=PType nowrap>type&nbsp;</td>
      <td class=PParameter nowrap>T</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%>int</td>
    </tr>
    <tr>
      <td class=PAfterParameters colspan=5>) extends uvm_in_order_comparator #(T)</td></tr>
      </table></td></tr>
    </table></blockquote>
This class uses the uvm_built_in_* comparison, converter, and pair classes. </div></div><div class=CToolTip id="tt3"><div class=CClass>
    <blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype>
      <tr><td><table border=0 cellspacing=0 cellpadding=0><tr>
      <td class=PBeforeParameters colspan=5>class uvm_in_order_class_comparator #(</td>      </tr><tr><td>&nbsp;&nbsp;&nbsp;</td>      <td class=PType nowrap>type&nbsp;</td>
      <td class=PParameter nowrap>T</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%> int</td>
    </tr>
    <tr>
      <td class=PAfterParameters colspan=5>) extends uvm_in_order_comparator #( T , uvm_class_comp #( T ) , uvm_class_converter #( T ) , uvm_class_pair #( T, T ) )</td></tr>
      </table></td></tr>
    </table></blockquote>
This class uses the uvm_class_* comparison, converter, and pair classes. </div></div><div class=CToolTip id="tt4"><div class=CGeneric>The <i>uvm_void</i> class is the base class for all UVM classes. </div></div><div class=CToolTip id="tt5"><div class=CClass>
    <blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>virtual class uvm_object extends uvm_void
  </td></tr></table></blockquote>The uvm_object class is the base class for all UVM data and hierarchical classes. </div></div><div class=CToolTip id="tt6"><div class=CClass>
    <blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>class uvm_report_object extends uvm_object
  </td></tr></table></blockquote>The uvm_report_object provides an interface to the UVM reporting facility. </div></div><div class=CToolTip id="tt7"><div class=CClass>
    <blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>virtual class uvm_component extends uvm_report_object
  </td></tr></table></blockquote>The uvm_component class is the root base class for UVM components. </div></div><div class=CToolTip id="tt8"><div class=CClass>
    <blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype>
      <tr><td><table border=0 cellspacing=0 cellpadding=0><tr>
      <td class=PBeforeParameters nowrap>class uvm_algorithmic_comparator #(</td>      <td class=PType nowrap>type&nbsp;</td>
      <td class=PParameter nowrap>BEFORE</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%>int,</td>
</tr><tr><td></td>      <td class=PType nowrap>type&nbsp;</td>
      <td class=PParameter nowrap>AFTER</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%>int,</td>
</tr><tr><td></td>      <td class=PType nowrap>type&nbsp;</td>
      <td class=PParameter nowrap>TRANSFORMER</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%>int</td>
      <td class=PAfterParameters nowrap>) extends uvm_component</td></tr>
      </table></td></tr>
    </table></blockquote>
Compares two streams of data objects of different types, <i>BEFORE</i> and <i>AFTER</i>.</div></div><div class=CToolTip id="tt9"><div class=CMethod>
    <blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype>
      <tr><td><table border=0 cellspacing=0 cellpadding=0><tr>
      <td class=PBeforeParameters nowrap>function new(</td>      <td class=PType nowrap>string&nbsp;</td>
      <td class=PParameter nowrap>name,</td>
      <td class=PDefaultValuePrefix>&nbsp;&nbsp;</td>
      <td class=PDefaultValue width=100%></td>
</tr><tr><td></td>      <td class=PType nowrap>uvm_component&nbsp;</td>
      <td class=PParameter nowrap>parent</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%>null,</td>
</tr><tr><td></td>      <td class=PType nowrap>TRANSFORMER&nbsp;</td>
      <td class=PParameter nowrap>transformer</td>
      <td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td>
      <td class=PDefaultValue width=100%>null</td>
      <td class=PAfterParameters nowrap>)</td></tr>
      </table></td></tr>
    </table></blockquote>
Creates an instance of a specialization of this class. </div></div><!--END_ND_TOOLTIPS-->

<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>